package com.gitee.wsl.func.comparable

import com.gitee.wsl.base.Objects
import com.gitee.wsl.ext.base.test

fun interface Equator<T> {

    fun equate(o1:T,  o2:T):Boolean

    companion object{
        fun<T> default() = Equator<T>{a,b->
          Objects.equals(a,b)
        }

        fun<T: Comparable<T>> composable() = Equator<T>{a,b->
            a == b
        }
    }
}

fun<T> Comparator<T>.toEquator() = Equator<T>{a,b->this.test(a,b)}